<template>
  <view class="container">
    <view style="font-size: 28rpx; font-family: PingFang SC, PingFang SC; font-weight: bold; color: #000000; margin: 30rpx">提现到微信</view>
    <!-- 输入提现金额 -->
    <view class="iptmoney">
      <view style="font-size: 50rpx; font-family: PingFang SC, PingFang SC; font-weight: bold; color: #000000">￥</view>
      <input type="text" placeholder="请输入提现金额" v-model="money" style="margin-left: 30rpx; font-size: 28rpx; font-family: PingFang SC, PingFang SC; font-weight: 500" />
      <view style="margin-left: 120rpx; font-weight: bold; color: #3553e8; font-size: 28rpx" @click="allmoney">全部提现</view>
    </view>
    <view style="font-size: 28rpx; font-family: PingFang SC, PingFang SC; font-weight: 500; color: #999999; margin-left: 30rpx">可提现金额￥{{ okmoney }}</view>

    <!-- 确定按钮 -->
    <view class="fnok" @click="tixian">确定</view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      okmoney: '',
      money: ''
    };
  },
  methods: {
    async tixian(money) {
      const res = await uni.$http.post('/withdraw/add', {
        money: this.money
      });
      console.log(res);
      uni.showToast({
        title: res.data.msg,
        icon: 'none'
      });
      if (res.data.code == 1) {
        this.okmoney = this.okmoney - this.money;
        this.money = '';
        // uni.navigateBack();
      }
    },
    // 全部提现
    allmoney() {
      this.money = this.okmoney;
    }
  },
  onLoad(e) {
    if (e.money) {
      console.log(e.money);
      this.okmoney = e.money;
    }
  }
};
</script>

<style lang="scss" scoped>
.container {
  box-sizing: border-box;
  .iptmoney {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    width: 690rpx;
    height: 120rpx;
    margin: 22rpx 30rpx;
    background: #ffffff;
    border-radius: 20rpx 20rpx 20rpx 20rpx;
    border: 2rpx solid #f8f8f8;
  }
  .fnok {
    box-sizing: border-box;
    position: absolute;
    bottom: 80rpx;
    width: 670rpx;
    height: 90rpx;
    margin: 0 40rpx;
    text-align: center;
    line-height: 90rpx;
    color: #fff;
    background: #3553e8;
    border-radius: 100rpx 100rpx 100rpx 100rpx;
  }
}
</style>
